/**
 * @param {number[]} nums
 * @param {number} val
 * @return {number}
 */
var removeElement = function(nums, val) {
    let pre = 0, tail = nums.length - 1;
    while(pre <= tail) {
        if(nums[pre] == val) {
            nums[pre] = nums[tail];
            tail--;
        } else {
            pre++;
        }
    }
    return pre;
};
function run () {
    let args = [
        [0,1,2,2,3,0,4,2],2
    ];
    return removeElement(...args);
}
module.exports = run;